Resize ================= 对输入图像使用给定的插值方式去调整为给定的尺寸大小。 输入: - **input** - 输入数据的地址 - **param** - 算子计算所需参数的结构体。其各成员见下述。 - **core_mask** - 核掩码。 **ResizeParameter定义:** .. code-block:: c :linenos: typedef struct ResizeParameter { int* input_shape_; // 输入张量形状 int* output_shape_; // 输出张量形状 int* x_lefts_; // 用于存储预处理结果 int* x_rights_; // 用于存储预处理结果 int* y_tops_; // 用于存储预处理结果 int* y_bottoms_; // 用于存储预处理结果 void* x_weights_; // 用于存储预处理结果 void* y_weights_; // 用于存储预处理结果 void* line_buffers_; // 用于存储中间结果 int method_; // 所用的插值方法,0:最邻近插值,1:双线性插值,2:双三次插值 int coordinate_transform_mode_; // 像素点对齐方式,0:非对称,1:中心对齐,2:偏移半像素 float cubic_coeff_; // 一个仅在双三次插值中使用到的系数 } ResizeParameter; 输出: - **output** - 输出地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持int8, fp32 - MT7004 支持fp16, fp32 **共享/私有存储版本:** .. c:function:: void i8_resize_anycore(int8_t* input, int8_t* output, ResizeParameter* param, int core_mask) .. c:function:: void hp_resize_anycore(half* input, half* output, ResizeParameter* param, int core_mask) .. c:function:: void fp_resize_anycore(float* input, float* output, ResizeParameter* param, int core_mask) 私有及共享空间版本均使用这些函数。 **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 30 void TestResizeFp32SMC(int* input_shape, int* output_shape, ResizeMethod method, CoordinateTransformMode mode, float cubic_coeff, int core_mask) { int core_id = get_core_id(); int core_num = GetCoreNum(core_mask); int logic_core_id = GetLogicCoreId(core_mask, core_id); float* input = (float*)0x84000000; // 测试私有空间时地址设置在私有空间内即可 float* output = (float*)0x85000000; ResizeParameter* param = (ResizeParameter*)0x86000000; if (logic_core_id == 0) { param->coordinate_transform_mode_ = mode; param->method_ = method; param->cubic_coeff_ = cubic_coeff; param->input_shape_ = (int*)0x87000000; memcpy(param->input_shape_, input_shape, sizeof(int) * 4); param->output_shape_ = (int*)0x87100000; memcpy(param->output_shape_, output_shape, sizeof(int) * 4); param->line_buffers_ = (void*)0x88000000; param->x_lefts_ = (int*)0x89000000; param->x_rights_ = (int*)0x8A000000; param->y_bottoms_ = (int*)0x8B000000; param->y_tops_ = (int*)0x8C000000; param->x_weights_ = (void*)0x8D000000; param->y_weights_ = (void*)0x8E000000; if (method == BILINEAR) { PrepareResizeBilinear(param); // 做预处理 } else if (method == CUBIC) { PrepareResizeBicubic(param, cubic_coeff); // 做预处理 } } sys_bar(0, core_num); // 初始化参数完成后进行同步 fp_resize_anycore(input, check, param, core_mask); } void main(){ int input_shape[4] = {2, 4, 4, 4}; int output_shape[4] = {2, 8, 8, 4}; ResizeMethod method = NEAREST; CoordinateTransformMode mode = ALIGN_CORNERS; float cubic_coeff = -0.75; int core_mask = 0b1111; // 测试单核时核掩码设置为0b0001即可 TestResizeFp32SMC(input_shape, output_shape, method, mode, cubic_coeff, core_mask); }